// directives/index.js

const directivesContext = import.meta.glob('./**/*.js', { eager: true })

const loadDirectives = app => {
  Object.keys(directivesContext).forEach(directive => {
    const directiveConfig = directivesContext[directive]
    /**
     * 兼容 import export 和 require module.export 两种规范
     */
    const ctrl = directiveConfig.default || directiveConfig
    app.directive(ctrl.name, ctrl)
  })
}

export default loadDirectives